


import django_filters
from .models import Book

class BookFilter(django_filters.FilterSet):
    min_price = django_filters.NumberFilter(field_name='price', lookup_expr='gte')
    max_price = django_filters.NumberFilter(field_name='price', lookup_expr='lte')
    author_name = django_filters.CharFilter(field_name='author__name', lookup_expr='icontains')
    published_after = django_filters.DateFilter(field_name='publish_date', lookup_expr='gte')
    published_before = django_filters.DateFilter(field_name='publish_date', lookup_expr='lte')
    
    class Meta:
        model = Book
        fields = ['status', 'author', 'publisher']